package com.minglead.crawler.enums;

import cn.hutool.core.util.ObjectUtil;

public enum CrawlerMediaEnum {
    TOUTIAO("0", "今日头条"),
    WEIBO("1", "微博"),
    XIAOHONGSHU("2", "小红书"),
    CHINANEWSNETWORK("3", "中国新闻网"),
    XINHUA("4", "新华网"),
    TENCENT("5", "腾讯新闻"),
    SOUGOUWECHAT("6", "搜狗微信"),
    FINANCESINA("7", "新浪财经"),
    CBOT("8", "芝加哥期货交易所"),
    INEDAILY("9", "上海国际能源交易中心"),
    GD_NATIONAL("10", "广东省统计局国民经济主要指标"),
    GD_SITUATION("11", "广东省统计局蔬菜瓜果生产情况"),
    GD_ADD("12", "广东省统计局工业增加值"),
    GD_PRODUCTION("13", "广东省统计局主要产品产量"),
    GD_INDUSTRY("14", "广东省统计局工业主要经济指标"),
    GD_TOTAL("15", "广东省统计局社会消费品零售总额"),
    GD_QUARTER("16", "广东省统计局广东省季度生产总值");


    private final String code;
    private final String desc;

    CrawlerMediaEnum(String code, String desc) {
        this.code = code;
        this.desc = desc;
    }

    //获取值
    public String getCode() {
        return code;
    }

    //获取描述
    public String getDesc() {
        return desc;
    }

    //根据code获取枚举
    public static CrawlerMediaEnum getEnum(String code) {
        if(ObjectUtil.isNotNull(code)){
            CrawlerMediaEnum[] values = CrawlerMediaEnum.values();
            for (CrawlerMediaEnum ele : values) {
                if (ele.code.equals(code)) {
                    return ele;
                }
            }
        }
        return null;
    }
}
